package hanlders

import (
	"aifuture.cloud/hanlders"
	tpreq "aifuture.cloud/request/tp"
	"aifuture.cloud/services/course"
	"aifuture.cloud/services/jiangzuo"
	"aifuture.cloud/services/nav"
	"aifuture.cloud/services/resource"
	"aifuture.cloud/services/system"
	"aifuture.cloud/services/tp"
	"github.com/gin-gonic/gin"
)

//深南教育首页轮廓图
//返回 导航菜单  数据结构  name 名称 排序 sort  [["name":"首页","sort":1]]
type IndexHandler struct {
}

func NewIndex() *IndexHandler {
	return &IndexHandler{}
}

func (i *IndexHandler) Nav(c *gin.Context) {
	//查询导航信息

	navSvc := nav.NewNavSvc()
	err, info := navSvc.Index()
	hanlders.HandlerError(err, c)
	data := make(map[string]interface{})
	data["navInfo"] = info
	//查询热门课程信息
	//课程查询器
	mockQueryInteraptor := course.NewMock()
	courseSvc := course.NewCourSvc(mockQueryInteraptor) //注入课程查询器
	err, courseinfo := courseSvc.List()
	hanlders.HandlerError(err, c)
	data["courseInfo"] = courseinfo
	//查询系统化学习路径
	mockSystemInter := system.NewSystemMock()
	systemSvc := system.NewSystemSvc(mockSystemInter)
	err, sysinfo := systemSvc.List()
	hanlders.HandlerError(err, c)
	data["systemInfo"] = sysinfo

	//查询导师讲座信息
	//1.0 初始化讲座处理器
	mockJiangzuoInter := jiangzuo.NewJiangzuoMock()
	jiangzuoSvc := jiangzuo.NewJianguoSvc(mockJiangzuoInter)
	err, jianzuoinfo := jiangzuoSvc.List()
	hanlders.HandlerError(err, c)
	data["jiangzuoinfo"] = jianzuoinfo
	//查询实训项目信息
	tpSvc := tp.NewTpSvc(tp.NewTpMock())
	var tagReq tpreq.TpReq
	hanlders.HandlerError(c.ShouldBind(&tagReq), c)
	err, tpList := tpSvc.List(&tagReq)
	hanlders.HandlerError(err, c)
	data["tpInfo"] = tpList


	//
	//查询实训项目信息
	resvc := resource.NewResourceSvc(resource.NewResourceProxy())
	//查询资源中心
	err,resList:=resvc.List()
	hanlders.HandlerError(err, c)
	data["resInfo"] = resList
	hanlders.SuccessResponseHandler(c, data)
}
